//
//  SearchResultViewController.m
//  fp
//
//  Created by xingshuai on 2020/11/13.
//

#import "SearchResultViewController.h"

#import "RoomCollectionViewCell.h"
static NSString *identifier = @"XASearchResulsCollectionCellID";

@interface SearchResultViewController () <HomeSearchTextDelegate,UICollectionViewDelegate, UICollectionViewDataSource>

// 数据展示
@property (nonatomic, strong) UICollectionView *collection;

@end

@implementation SearchResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 设置首页导航样式
    self.currentnavType = XSCurrentNavViewTypeHome;
    
    self.delegate = self;
    
    [self creatClassSearViewUI];
}

#pragma mark -- HomeSearchTextDelegate
-(void)searchTextEndEdit:(NSString *)searchString {
    NSLog(@"没有接口：%@",searchString);
}

// 初始化ui
-(void)creatClassSearViewUI {
    [self.view addSubview:self.collection];
    [self.collection mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(15);
        make.top.equalTo(self.homeNavView.mas_bottom).offset(10);
        make.right.equalTo(self.view.mas_right).offset(-15);
        make.bottom.equalTo(self.view).offset(-5);
    }];
}

// 初始化collection
- (UICollectionView *)collection {
    if (!_collection) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.minimumLineSpacing = 20;
        flowLayout.minimumInteritemSpacing = 10;
        flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        _collection = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
        [_collection registerClass:[RoomCollectionViewCell class] forCellWithReuseIdentifier:identifier];
        _collection.showsHorizontalScrollIndicator = NO;
        _collection.dataSource = self;
        _collection.delegate = self;
        _collection.backgroundColor = [UIColor clearColor];
        _collection.showsVerticalScrollIndicator = NO;
    }
    return _collection;
}

#pragma mark - UICollectionViewDelegateFlowLayout
// 返回cell的尺寸大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake((self.collection.frame.size.width-30)/4, (self.collection.frame.size.width-30)/4/1.15);
}

#pragma mark - deleDate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 24;
}

// cell内容
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    RoomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    
    return cell;
}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
